<template>
  <div class="item">
    <div class="index">{{ computedIndex }}</div>
    <image
      class="head-image"
      :src="head_image"
      style="width: 100rpx; height: 100rpx"
    />
    <text class="nickname">{{ nickname }}</text>
    <div class="property">
      <image
        class="tomato"
        src="/static/tomato.png"
        style="width: 64rpx; height: 64rpx"
      />
      <text>{{ tomato }}</text>
    </div>
  </div>
</template>

<script>
export default {
  name: "rankinglist-item",
  props: {
    index: {
      type: Number,
      required: true,
    },
    nickname: {
      type: String,
      required: true,
    },
    head_image: {
      type: String,
      required: true,
    },
    tomato: {
      type: Number,
      required: true,
    },
    limit: {
      type: Number,
      required: true,
    },
  },
  computed: {
    computedIndex() {
      if (this.index === -1) {
        return `大于${this.limit}`;
      } else {
        return this.index;
      }
    },
  },
};
</script>

<style scoped>
.item {
  width: 100%;
  height: 160rpx;
  display: flex;
  line-height: 160rpx;
  align-items: center;
  position: relative;
}
.item > .head-image {
  position: absolute;
  left: 150rpx;
  margin-right: 16rpx;
}
.item > .index {
  position: absolute;
  left: 60rpx;
  display: flex;
  justify-content: center;
  width: 9px;
  white-space: nowrap;
}
.item > .nickname {
    position: absolute;
    left: 266rpx;
}
.item .property {
  position: absolute;
  left: calc(100vw - 200rpx);
  display: flex;
  align-items: center;
}
.tomato {
  margin-right: 27rpx;
}
</style>